package com.atcumt.Huawei;

import java.util.Scanner;

/**
 * DNA序列
 * 输入：
 * ACGT
 * 2
 *
 * 输出：
 * CG
 */
public class HJ5 {

    // 滑动窗口
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int n = sc.nextInt();
        int maxSum = 0; // GC字母个数
        int index = 0;

        for (int i = 0; i < s.length() - n; i++) {
            int gcSum = 0;
            for (int j = i; j < i + n; j++) {
                if (s.charAt(j) == 'C' || s.charAt(j) == 'G') {
                    gcSum++;
                }
            }
            if (gcSum > maxSum) {
                maxSum = gcSum;
                index = i;
                if (gcSum == n) {
                    System.out.println(s.substring(index, index + n));
                }
            }
        }
        System.out.println(s.substring(index, index + n));
    }
}
